package io;

import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;

public class StoringAndRecoveringData {
    public static void main(String[] args) throws IOException {
//        DataOutputStream out = new DataOutputStream(
//                new BufferedOutputStream(
//                        new FileOutputStream("src/main/java/io/Data.txt")));
//        out.writeDouble(3.14159);
//        out.writeUTF("That was pi");
//        out.writeDouble(1.41413);
//        out.writeUTF("Square root of 2");
//        out.close();
        DataInputStream in = new DataInputStream(
                new BufferedInputStream(
                        new FileInputStream("src/main/java/io/Data.txt")));
        System.out.println(in.readDouble());
        System.out.println(in.readUTF());
        // Only readUTF() will recover the
        // Java-UTF String properly:
        System.out.println(in.readDouble());
        System.out.println(in.readUTF());
    }
}
